package com.intel.two.vo;

import com.intel.two.config.SystemConfig;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author: Zz
 * @Description: TODO
 * @DateTime: 2022/10/13 17:06
 **/
/*
 *                        .::::.
 *                      .::::::::.
 *                     :::::::::::
 *                  ..:::::::::::'
 *               '::::::::::::'
 *                 .::::::::::
 *            '::::::::::::::..
 *                 ..::::::::::::.
 *               ``::::::::::::::::
 *                ::::``:::::::::'        .:::.
 *               ::::'   ':::::'       .::::::::.
 *             .::::'      ::::     .:::::::'::::.
 *            .:::'       :::::  .:::::::::' ':::::.
 *           .::'        :::::.:::::::::'      ':::::.
 *          .::'         ::::::::::::::'         ``::::.
 *      ...:::           ::::::::::::'              ``::.
 *     ````':.          ':::::::::'                  ::::..
 *                        '.:::::'                    ':'````..
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Result {
    private int code;
    private String msg;
    private Object data;

    /**
     * 成功*/
    public static Result ok(Object data){
        //魔法值：直接写值的(数字、字符串等)，开发中应该避免魔法值，要么用枚举要么用常量
//        return new R(200,"OK",data);
        return new Result(SystemConfig.R_OK,"OK",data);
    }
    /**
     * 成功*/
    public static Result ok(){
        return ok(null);
    }
    /**
     * 失败*/
    public static Result fail(String msg){
        return new Result(SystemConfig.R_FAIL,msg,null);
    }
    /**
     * 失败*/
    public static Result fail(){
        return fail("FAIL");
    }
}
